<?php

/**
 * Devis form base class.
 *
 * @method Devis getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDevisForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                     => new sfWidgetFormInputHidden(),
      'date'                   => new sfWidgetFormDate(),
      'reference'              => new sfWidgetFormInputText(),
      'lieu_livraison'         => new sfWidgetFormInputText(),
      'observation'            => new sfWidgetFormInputText(),
      'total_ht'               => new sfWidgetFormInputText(),
      'total_remise'           => new sfWidgetFormInputText(),
      'taux_remise'            => new sfWidgetFormInputText(),
      'total_tva'              => new sfWidgetFormInputText(),
      'total_ttc'              => new sfWidgetFormInputText(),
      'total_netht'            => new sfWidgetFormInputText(),
      'total_fodec'            => new sfWidgetFormInputText(),
      'date_livraison'         => new sfWidgetFormDate(),
      'date_validite'          => new sfWidgetFormDate(),
      'mode_paiement_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ModePaiement'), 'add_empty' => true)),
      'id_client'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'add_empty' => true)),
      'id_representant'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Representant'), 'add_empty' => true)),
      'num_up_echeance'        => new sfWidgetFormInputText(),
      'statut'                 => new sfWidgetFormChoice(array('choices' => array('Commander' => 'Commander', 'Non Commander' => 'Non Commander'))),
      'bon_commande_client_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BonCommandeClient'), 'add_empty' => true)),
      'valider'                => new sfWidgetFormInputCheckbox(),
      'id_departement'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Departement'), 'add_empty' => true)),
      'created_at'             => new sfWidgetFormDateTime(),
      'updated_at'             => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'date'                   => new sfValidatorDate(),
      'reference'              => new sfValidatorString(array('max_length' => 20)),
      'lieu_livraison'         => new sfValidatorString(array('max_length' => 70, 'required' => false)),
      'observation'            => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'total_ht'               => new sfValidatorNumber(array('required' => false)),
      'total_remise'           => new sfValidatorNumber(array('required' => false)),
      'taux_remise'            => new sfValidatorNumber(array('required' => false)),
      'total_tva'              => new sfValidatorNumber(array('required' => false)),
      'total_ttc'              => new sfValidatorNumber(array('required' => false)),
      'total_netht'            => new sfValidatorNumber(array('required' => false)),
      'total_fodec'            => new sfValidatorNumber(array('required' => false)),
      'date_livraison'         => new sfValidatorDate(array('required' => false)),
      'date_validite'          => new sfValidatorDate(array('required' => false)),
      'mode_paiement_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ModePaiement'), 'required' => false)),
      'id_client'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'required' => false)),
      'id_representant'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Representant'), 'required' => false)),
      'num_up_echeance'        => new sfValidatorNumber(array('required' => false)),
      'statut'                 => new sfValidatorChoice(array('choices' => array(0 => 'Commander', 1 => 'Non Commander'), 'required' => false)),
      'bon_commande_client_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BonCommandeClient'), 'required' => false)),
      'valider'                => new sfValidatorBoolean(array('required' => false)),
      'id_departement'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Departement'), 'required' => false)),
      'created_at'             => new sfValidatorDateTime(),
      'updated_at'             => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('devis[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Devis';
  }

}
